package com.chixing.entity;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import java.io.Serializable;
import java.time.LocalDateTime;

/**
 * <p>
 * 用户消息关系表（含消息推送状态）
 * </p>
 *
 * @author smith
 * @since 2025-10-28
 */
@TableName("user_message")
public class UserMessage implements Serializable {

    private static final long serialVersionUID = 1L;

    /**
     * 主键ID
     */
    @TableId(value = "id", type = IdType.AUTO)
    private Long id;

    /**
     * 关联 message.message_id
     */
    private String messageId;

    /**
     * 接收用户ID
     */
    private Long userId;

    /**
     * 消息状态：UNREAD=未读 / DELIVERED=已送达 / READ=已读 / EXPIRED=过期未送达
     */
    private String status;

    /**
     * 是否已发送到MQ：0=未发送，1=已发送
     */
    private Integer isPushed;

    /**
     * 送达时间（WebSocket 成功推送时填写）
     */
    private LocalDateTime deliveredAt;

    /**
     * 阅读时间（用户打开消息时填写）
     */
    private LocalDateTime readAt;

    /**
     * Redis 半消息过期后入库时间
     */
    private LocalDateTime expiredAt;

    /**
     * 创建时间
     */
    private LocalDateTime createdAt;

    /**
     * 关联订单ID
     */
    private Long orderId;

    public Long getOrderId() {
        return orderId;
    }

    public void setOrderId(Long orderId) {
        this.orderId = orderId;
    }

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }
    public String getMessageId() {
        return messageId;
    }

    public void setMessageId(String messageId) {
        this.messageId = messageId;
    }
    public Long getUserId() {
        return userId;
    }

    public void setUserId(Long userId) {
        this.userId = userId;
    }
    public String getStatus() {
        return status;
    }

    public void setStatus(String status) {
        this.status = status;
    }
    public Integer getIsPushed() {
        return isPushed;
    }

    public void setIsPushed(Integer isPushed) {
        this.isPushed = isPushed;
    }
    public LocalDateTime getDeliveredAt() {
        return deliveredAt;
    }

    public void setDeliveredAt(LocalDateTime deliveredAt) {
        this.deliveredAt = deliveredAt;
    }
    public LocalDateTime getReadAt() {
        return readAt;
    }

    public void setReadAt(LocalDateTime readAt) {
        this.readAt = readAt;
    }
    public LocalDateTime getExpiredAt() {
        return expiredAt;
    }

    public void setExpiredAt(LocalDateTime expiredAt) {
        this.expiredAt = expiredAt;
    }
    public LocalDateTime getCreatedAt() {
        return createdAt;
    }

    public void setCreatedAt(LocalDateTime createdAt) {
        this.createdAt = createdAt;
    }

    @Override
    public String toString() {
        return "UserMessage{" +
                "id=" + id +
                ", messageId='" + messageId + '\'' +
                ", userId=" + userId +
                ", status='" + status + '\'' +
                ", isPushed=" + isPushed +
                ", deliveredAt=" + deliveredAt +
                ", readAt=" + readAt +
                ", expiredAt=" + expiredAt +
                ", createdAt=" + createdAt +
                ", orderId=" + orderId +
                '}';
    }
}
